//
//  TPTestMain.java
//
//  Created by David J. Hinson on 2/6/10.
//  Copyright 2010 TweetPhoto, Inc. All rights reserved.

package com.tweetphoto.api;

import com.tweetphoto.api.R;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class TPTestMain extends Activity {
	
	private static final String TAG = "TPAPI";
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        TweetPhoto tweetPhoto = new TweetPhoto();
                
        // --- TweetPhoto Sign In
        // --- APIKey, Service Name (Twitter, Foursquare, Facebook), is OAuth (true/false), username / userKey, password / userSecret
        Profile profile = tweetPhoto.signIn("your_api_key_here", "Twitter_or_Foursquare_or_Facebook", false, "your_identity_token", "your_identity_secret");
        if (profile!=null) { 
        	Log.i(TAG, "TweetPhoto Sign In: " + profile.describe());
        	}
        
        // Link a service to the currently auth'd user.
        // TweetPhotoResponse response = tweetPhoto.linkService(tweetPhoto.m_APIKey, "identityToken", "identitySecret", "Facebook_or_Twitter_or_Foursquare");
        // if (response!=null) { 
        //	Log.i(TAG, "TweetPhoto Link Service: " + response.describe());
        //	}
        
        // Un-Link a service linked to the currently auth'd user.
        // TweetPhotoResponse response = tweetPhoto.unlinkService("Facebook");
        // if (response!=null) { 
        //	Log.i(TAG, "TweetPhoto Un-Link Service: " + response.describe());
        //	}
        
        // Query for linked services connected to the currently auth'd user
        // Profiles profiles = tweetPhoto.linkedServices();
        // if (profiles!=null) {
        //    Log.i(TAG, "TweetPhoto Profiles with Linked Services: " + profiles.describe());
        //    for (int i=0; i<profiles.m_list.size(); i++) {
        //     	Profile profile2 = (Profile)profiles.m_list.get(i);
        //        Log.i(TAG, "TweetPhoto Profiles with Linked Services: " + profile2.describe());
        //     	}            
        //	}
        
        // --- Add Photo Comment
        // AddPhotoCommentResponse comment = tweetPhoto.comment(907516, 10494868, "Test... will be deleted next.");
        // if (comment!=null) {
        //	Log.i(TAG, "TweetPhoto Photo Comment: " + comment.describe());
        //	}
        
        // --- Delete a Photo Comment
        // TweetPhotoResponse delete = tweetPhoto.deleteComment(907516, 10494868, 2816825);
        // if (delete!=null) {
        // 	Log.i(TAG, "TweetPhoto Photo Delete Comment: " + delete.describe());
        //	}
        
        // --- Favorite a Photo
        // TweetPhotoResponse favorite = tweetPhoto.favorite(907516, 10494868);
        // if (favorite!=null) {
        // 	Log.i(TAG, "TweetPhoto Photo Favorite: " + favorite.describe());
        //	}
        
        // --- Delete a Photo Favorite
        // TweetPhotoResponse delete = tweetPhoto.deleteFavorite(907516, 10494868);
        // if (delete!=null) {
        // 	Log.i(TAG, "TweetPhoto Photo Delete Favorite: " + delete.describe());
        //	}
        
        // --- Delete a Photo
        // TweetPhotoResponse delete = tweetPhoto.deletePhoto(10494354);
        // if (delete!=null) {
        // 	Log.i(TAG, "TweetPhoto Photo Delete: " + delete.describe());
        //	}
        
        // --- Get All User Comments, sort asc / desc
        // Comments comments = tweetPhoto.userComments(907516, "desc");
        // if (comments!=null) {
        // 	Log.i(TAG, "TweetPhoto User Comments: " + comments.describe());
        // 	for (int i=0; i<comments.m_list.size(); i++) {
        // 		Comment comment = (Comment)comments.m_list.get(i);
        //    	Log.i(TAG, "TweetPhoto All User Comment: " + comment.describe());
        // 		}
        //	}
        
        // --- Get User Comments (page size 10, offset 0, sort asc / desc
        // Comments comments = tweetPhoto.userComments(907516, 10, 0, "desc");
        // if (comments!=null) {
        // 	Log.i(TAG, "TweetPhoto User Comments: " + comments.describe());
        // 	for (int i=0; i<comments.m_list.size(); i++) {
        // 		Comment comment = (Comment)comments.m_list.get(i);
        //     	Log.i(TAG, "TweetPhoto User Comment: " + comment.describe());
        // 		}
        //	}
        
        // --- Get All Photo Comments, sort asc / desc
        // Comments comments = tweetPhoto.photoComments(10562796, "desc");
        // if (comments!=null) {
        //	Log.i(TAG, "TweetPhoto Photo Comments: " + comments.describe());
        // 	for (int i=0; i<comments.m_list.size(); i++) {
        // 		Comment comment = (Comment)comments.m_list.get(i);
        //    	Log.i(TAG, "TweetPhoto All Photo Comment: " + comment.describe());
        // 		}
        //	}
        
        // --- Get Photo Comments, page size=10, offset=0, sort asc / desc
        // Comments comments = tweetPhoto.photoComments(10562796, 10, 0, "desc");
        // if (comments!=null) {
        //	Log.i(TAG, "TweetPhoto Photo Comments: " + comments.describe());
        // 	for (int i=0; i<comments.m_list.size(); i++) {
        // 		Comment comment = (Comment)comments.m_list.get(i);
        //    	Log.i(TAG, "TweetPhoto All Photo Comment: " + comment.describe());
        // 		}
        //	}
        
        // --- Get Photo Comments for User, sort asc / desc
        // Comments comments = tweetPhoto.photoCommentsByUser(907516, 10, 0, "desc");
        // if (comments!=null) {
        //	Log.i(TAG, "TweetPhoto User Photo Comments: " + comments.describe());
        // 	for (int i=0; i<comments.m_list.size(); i++) {
        // 		Comment comment = (Comment)comments.m_list.get(i);
        //    	Log.i(TAG, "TweetPhoto User Photo Comment: " + comment.describe());
        // 		}
        //	}
        
        // --- Get Favorites for User, page size=10, index=0, sort asc / desc
        // Favorites favorites = tweetPhoto.favorites(907516, 10, 0, "desc");
        // if (favorites!=null) {
        //	Log.i(TAG, "TweetPhoto User Favorites: " + favorites.describe());
        // 	for (int i=0; i<favorites.m_list.size(); i++) {
        // 		Favorite favorite = (Favorite)favorites.m_list.get(i);
        //    	Log.i(TAG, "TweetPhoto User Favorite: " + favorite.describe());
        //    	Log.i(TAG, "TweetPhoto User Favorite Photo: " + favorite.m_photo.describe());
        //    	Log.i(TAG, "TweetPhoto User Favorite Photo User: " + favorite.m_photo.m_user.describe());
        // 		}
        //	}
         
        // --- Get All Favorites for User, sort asc / desc
        // Favorites favorites = tweetPhoto.favorites(907516, "asc");
        //  if (favorites!=null) {
        // 	Log.i(TAG, "TweetPhoto User Favorites: " + favorites.describe());
        //  	for (int i=0; i<favorites.m_list.size(); i++) {
        //  		Favorite favorite = (Favorite)favorites.m_list.get(i);
        //     	Log.i(TAG, "TweetPhoto User Favorite: " + favorite.describe());
        //     	Log.i(TAG, "TweetPhoto User Favorite Photo: " + favorite.m_photo.describe());
        //     	Log.i(TAG, "TweetPhoto User Favorite Photo User: " + favorite.m_photo.m_user.describe());
        //  		}
        // 	}
        
        // --- Get Friends (page size 10, offset 0, sort asc / desc)
        // Profiles friends = tweetPhoto.friends(907516, 10, 0, "desc");
        // if (friends!=null) {
        // Log.i(TAG, "TweetPhoto Friends: " + friends.describe());
        // for (int i=0; i<friends.m_list.size(); i++) {
        //  		Profile friend = (Profile)friends.m_list.get(i);
        //     	Log.i(TAG, "TweetPhoto Friend: " + friend.describe());
        // 		}
        //	}
        
        // --- Get All Friends (sort asc / desc) --- CAREFUL: USER COULD HAVE THOUSANDS OF FRIENDS!!!
        // Profiles friends = tweetPhoto.friends(907516, "asc");
        // if (friends!=null) {
        // 	Log.i(TAG, "TweetPhoto Friends: " + friends.describe());
        // 	for (int i=0; i<friends.m_list.size(); i++) {
        // 		Profile friend = (Profile)friends.m_list.get(i);
        //     	Log.i(TAG, "TweetPhoto Friend: " + friend.describe());
        // 		}
        //	}
        
        // --- Get Leaderboard (viewed, voted, commented)
        // Photos photos = tweetPhoto.leaderboard("viewed");
        // if (photos!=null) {
        // 	Log.i(TAG, "TweetPhoto Leaderboard: " + photos.describe());
        // 	for (int i=0; i<photos.m_list.size(); i++) {
        // 		Photo photo = (Photo)photos.m_list.get(i);
        //     	Log.i(TAG, "TweetPhoto Photo: " + photo.describe());
        // 		}
        //	}
        
        // --- Get Next Photo
        // Photo photo = tweetPhoto.next(10575157);
        // if (photo!=null) {
        // 	Log.i(TAG, "TweetPhoto Next: " + photo.describe());
        //	}
         
        // --- Get Previous Photo
        // Photo photo = tweetPhoto.previous(10575289);
        // if (photo!=null) {
        // 	Log.i(TAG, "TweetPhoto Previous: " + photo.describe());
        //	}
        
        // --- Get All Photos (sort asc/desc)
        // Photos photos = tweetPhoto.photos(907516, "asc");
        // if (photos!=null) {
        // 	Log.i(TAG, "TweetPhoto All Photos: " + photos.describe());
        // 	for (int i=0; i<photos.m_list.size(); i++) {
        // 		Photo photo = (Photo)photos.m_list.get(i);
        //     	Log.i(TAG, "TweetPhoto Photo: " + photo.describe());
        // 		}
        //	}
         
        // --- Get Photos (page size=10, index=0, sort asc/desc)
        // Photos photos = tweetPhoto.photos(907516, 10, 0, "asc");
        // if (photos!=null) {
        // 	Log.i(TAG, "TweetPhoto All Photos: " + photos.describe());
        // 	for (int i=0; i<photos.m_list.size(); i++) {
        // 		Photo photo = (Photo)photos.m_list.get(i);
        //     	Log.i(TAG, "TweetPhoto Photo: " + photo.describe());
        // 		}
        //	}
        
        // --- Get Photo Metadata
        // Photo photo = tweetPhoto.photoMetaData(10085923);
        // if (photo!=null) {
        // 	Log.i(TAG, "TweetPhoto Photo MetaData: " + photo.describe());
        //    for (int i=0; i<photo.m_photoComments.size(); i++) {
        //     		Comment comment = (Comment)photo.m_photoComments.get(i);
        //         	Log.i(TAG, "TweetPhoto Photo Comment: " + comment.describe());
        //     		}
        //	}
        
        // --- Get Public Feed
        // SocialFeed social = tweetPhoto.publicFeed(10, 0, "desc");
        // if (social!=null) {
        // 	Log.i(TAG, "TweetPhoto Public Feed: " + social.describe());
        //    for (int i=0; i<social.m_list.size(); i++) {
        //     		SocialFeedEvent event = (SocialFeedEvent)social.m_list.get(i);
        //         	Log.i(TAG, "TweetPhoto Social Feed Event: " + event.describe());
        //     		}
        //	}
        
        // --- Get Social Feed by User Id
        // SocialFeed social = tweetPhoto.socialFeed(907516, 10, 0, "desc");
        // if (social!=null) {
        //  	Log.i(TAG, "TweetPhoto Social Feed: " + social.describe());
        //    for (int i=0; i<social.m_list.size(); i++) {
        //     		SocialFeedEvent event = (SocialFeedEvent)social.m_list.get(i);
        //         	Log.i(TAG, "TweetPhoto Social Feed Event: " + event.describe());
        //     		}
        //	}
        
        // --- Get Profile by User Id
        // Profile userProfile = tweetPhoto.userProfile(907516);
        // if (userProfile!=null) {
        //  	Log.i(TAG, "TweetPhoto Profile: " + userProfile.describe());
        //	}
        
        // --- Get Profile by User Name
        // Profile userProfile = tweetPhoto.userProfile("davidjhinson");
        // if (userProfile!=null) {
        //  	Log.i(TAG, "TweetPhoto Profile: " + userProfile.describe());
        //	}
        
        // --- Mark Photo as Viewed
        // TweetPhotoResponse view = tweetPhoto.view(907516, 10085923);
        // if (view!=null) {
        //  	Log.i(TAG, "TweetPhoto Viewed: " + view.describe());
        //	}
        
        // --- Delete Photo Location
        // TweetPhotoResponse view = tweetPhoto.deleteLocation(10085923);
        // if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Delete Location: " + view.describe());
        //	}
        
        // --- Set Photo Location
        // TweetPhotoResponse view = tweetPhoto.setLocation(10085923, (float)24.558521, (float)-81.78257);
        // if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Set Location: " + view.describe());
        //	}
        
        // --- Get User Settings
        // Settings settings = tweetPhoto.settings(907516);
        // if (settings!=null) {
        //  	Log.i(TAG, "TweetPhoto Settings: " + settings.describe());
        //	}
        
        // --- Set Map Type
        // Settings view = tweetPhoto.setMapType(907516, 1);
        // if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Set Map Type: " + view.describe());
        //	}
        
        // --- Set PIN
        //Settings view = tweetPhoto.setPIN(907516, 9999);
        //if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Set PIN: " + view.describe());
        //	}
        
        // --- Set Shorten Url (0=No, 1=Yes)
        // Settings view = tweetPhoto.setShortenUrl(907516, 1);
        // if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Set Shorten Url: " + view.describe());
        //	}
        
        // --- Set Do Not Tweet Favorite Photo (0=No, 1=Yes)
        // Settings view = tweetPhoto.setDoNotTweetFavoritePhoto(907516, 1);
        // if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Set Do Not Tweet Favorite Photo: " + view.describe());
        //	}
        
        // --- Set Hide Viewing Patterns (0=No, 1=Yes)
        // Settings view = tweetPhoto.setHideViewingPatterns(907516, 1);
        // if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Set Hide Viewing Patterns: " + view.describe());
        //	}
        
        // --- Set Hide Votes (0=No, 1=Yes)
        // Settings view = tweetPhoto.setHideVotes(907516, 1);
        // if (view!=null) {
        // 	Log.i(TAG, "TweetPhoto Set Hide Votes: " + view.describe());
        //	}

        // --- Upload a photo
		// try {	        
		//	 FileOutputStream fos = super.openFileOutput("TestFile.jpg", MODE_WORLD_READABLE);

		//	 Bitmap bm = BitmapFactory.decodeResource(this.getResources(), R.drawable.splash);
		//	 bm.compress(CompressFormat.JPEG, 75, fos);

		//	 fos.flush();
		//	 fos.close();
			 
		//	 File photo = new File("/data/data/com.tweetphoto.api.test/files", "TestFile.jpg");
		//	 FileEntity file = new FileEntity(photo, "image/jpg");
					   
	        // --- Upload a photo
	    //    TweetPhotoResponse response = tweetPhoto.uploadPhoto(file, "This is a sample", "Test, Java API, Demo", 24.558521, -81.78257, "image/jpg");
	        
	    //    if (response!=null) {
	    //        Log.i(TAG, "TweetPhoto Upload: " + response.describe());
	    //    	}
		//	}
		//catch (java.io.IOException e) {
		//	e.printStackTrace();
		// }
        
        // --- Vote (thumbsup / thumbsdown)
        // TweetPhotoResponse vote = tweetPhoto.vote(10612117, "thumbsup");
        // if (vote!=null) {
        // 	Log.i(TAG, "TweetPhoto Vote: " + vote.describe());
        //	}
        
        // --- Vote Status (thumbsup / thumbsdown)
        // VoteStatus vote = tweetPhoto.voteStatus(907516, 10612117);
        // if (vote!=null) {
        // 	Log.i(TAG, "TweetPhoto Vote Status: " + vote.describe());
        //	}
   }
}